package com.saikuo.service.service.impl;

import com.saikuo.service.api.ApiResultModel;
import com.saikuo.service.constant.ContextConfig;
import com.saikuo.service.dao.ICouponDao;
import com.saikuo.service.service.ICouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by shanchangyu on 16/11/03.
 */
@Service
public class CouponServiceImpl implements ICouponService {

    @Autowired
    private ICouponDao couponDao;

    @Override
    public ApiResultModel getUserCoupon(int userId, int status, int page) {
        int start = page > 0 ? page - 1 : page;
        return new ApiResultModel(couponDao.getUserCoupon(userId, status, start * ContextConfig.COUPON_PAGE_SIZE, ContextConfig.COUPON_PAGE_SIZE));
    }

    @Override
    public ApiResultModel getUserCouponAccordPrice(int userId, Double price, int page) {
        int start = page > 0 ? page - 1 : page;
        return new ApiResultModel(couponDao.getUserCouponAccordPrice(userId, price, start * ContextConfig.COUPON_PAGE_SIZE, ContextConfig.COUPON_PAGE_SIZE));
    }

}
